﻿<UserControl x:Class="CmdletHelpEditor.UI.UserControls.ParameterDescriptionControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:c="clr-namespace:CmdletHelpEditor.Controls"
             mc:Ignorable="d"
			 d:DataContext="{d:DesignInstance c:ClosableTabItem}"
             d:DesignWidth="740">
	<UserControl.Resources>
		<Style x:Key="ParamItemContStyle" TargetType="{x:Type ListViewItem}">
			<Style.Triggers>
				<DataTrigger Binding="{Binding Status}" Value="Missing">
					<Setter Property="Foreground" Value="Red"/>
				</DataTrigger>
				<DataTrigger Binding="{Binding Status}" Value="New">
					<Setter Property="Foreground" Value="Blue"/>
				</DataTrigger>
				<DataTrigger Binding="{Binding Status}" Value="Valid">
					<Setter Property="Foreground" Value="Green"/>
				</DataTrigger>
			</Style.Triggers>
		</Style>
	</UserControl.Resources>
	<DockPanel>
		<Grid DockPanel.Dock="Top"
              IsEnabled="{Binding EditorContext.ParamContext.ParamTextBoxEnabled}">
			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="10"/>
				<ColumnDefinition MinWidth="200"/>
				<ColumnDefinition Width="10"/>
				<ColumnDefinition MinWidth="200"/>
				<ColumnDefinition Width="10"/>
			</Grid.ColumnDefinitions>
			<Grid.RowDefinitions>
				<RowDefinition/>
				<RowDefinition/>
				<RowDefinition/>
				<RowDefinition/>
				<RowDefinition/>
				<RowDefinition/>
				<RowDefinition MinHeight="90"/>
				<RowDefinition/>
				<RowDefinition/>
				<RowDefinition/>
				<RowDefinition/>
				<RowDefinition/>
				<RowDefinition/>
				<RowDefinition Height="10"/>
				<RowDefinition/>
				<RowDefinition Height="10"/>
			</Grid.RowDefinitions>
			<TextBlock Grid.Row="0"
                       Grid.Column="1"
                       Text="Parameter name:"/>
			<TextBlock Grid.Row="0"
                       Grid.Column="3"
                       Text="Type:"/>
			<TextBox Grid.Row="1"
                     Grid.Column="1"
                     MaxLines="1"
                     IsReadOnly="True"
                     Text="{Binding EditorContext.ParamContext.CurrentParam.Name}"/>
			<TextBox Grid.Row="1"
                     Grid.Column="3"
                     MaxLines="1"
                     IsReadOnly="True"
                     Text="{Binding EditorContext.ParamContext.CurrentParam.Type}"/>
			<CheckBox Grid.Row="2"
                      Grid.Column="1"
                      Content="Mandatory"
                      IsEnabled="False"
                      IsChecked="{Binding EditorContext.ParamContext.CurrentParam.Mandatory}"/>
			<CheckBox Grid.Row="3"
                      Grid.Column="1"
                      Content="Dynamic"
                      IsEnabled="False"
                      IsChecked="{Binding EditorContext.ParamContext.CurrentParam.Dynamic}"/>
			<CheckBox Grid.Row="4"
                      Grid.Column="1"
                      Content="Value from remaining arguments"
                      IsEnabled="False"
                      IsChecked="{Binding EditorContext.ParamContext.CurrentParam.RemainingArgs}"/>
			<CheckBox Grid.Row="2"
                      Grid.Column="3"
                      Content="Value from pipeline"
                      IsEnabled="False"
                      IsChecked="{Binding EditorContext.ParamContext.CurrentParam.Pipeline}"/>
			<CheckBox Grid.Row="3"
                      Grid.Column="3"
                      Content="Value from pipeline by property name"
                      IsEnabled="False"
                      IsChecked="{Binding EditorContext.ParamContext.CurrentParam.PipelinePropertyName}"/>
			<CheckBox Grid.Row="4"
                      Grid.Column="3"
                      Content="Positional"
                      IsEnabled="False"
                      IsChecked="{Binding EditorContext.ParamContext.CurrentParam.Positional}"/>
			<TextBox Grid.Row="4"
                     Grid.Column="3"
                     MaxLines="1"
                     HorizontalAlignment="Center"
                     TextWrapping="Wrap"
                     Width="50"
                     IsEnabled="False"
                     Text="{Binding EditorContext.ParamContext.CurrentParam.Position}"/>
			<TextBlock Grid.Row="5"
                       Grid.Column="1"
                       Text="Parameter attributes:"/>
			<TextBlock Grid.Row="5"
                       Grid.Column="3"
                       Text="Aliases:"/>
			<ListBox Grid.Row="6"
                     Grid.Column="1"
                     Background="#FAFAFA"
                     ItemsSource="{Binding EditorContext.ParamContext.CurrentParam.Attributes}">
				<ListBox.ItemsPanel>
					<ItemsPanelTemplate>
						<UniformGrid Rows="4" />
					</ItemsPanelTemplate>
				</ListBox.ItemsPanel>
			</ListBox>
			<ListBox Grid.Row="6"
                     Grid.Column="3"
                     Background="#FAFAFA"
                     ItemsSource="{Binding EditorContext.ParamContext.CurrentParam.Aliases}">
				<ListBox.ItemsPanel>
					<ItemsPanelTemplate>
						<UniformGrid Rows="4" />
					</ItemsPanelTemplate>
				</ListBox.ItemsPanel>
			</ListBox>
			<TextBlock Grid.Row="7"
                       Grid.Column="1"
                       Text="Parameter description:"/>
			<TextBox Grid.Row="8"
					 Grid.Column="1"
					 Grid.ColumnSpan="3"
					 MinLines="11"
					 MaxLines="11"
					 Text="{Binding EditorContext.ParamContext.CurrentParam.Description, UpdateSourceTrigger=PropertyChanged}"
					 Tag="AllowFormat"/>
			<TextBlock Grid.Row="11"
                       Grid.Column="1"
                       Text="Default value:"/>
            <TextBox Grid.Row="12"
                     Grid.Column="1"
                     Grid.ColumnSpan="3"
                     MaxLines="1"
                     ToolTip="Specifies the default value for the parameter"
                     Text="{Binding EditorContext.ParamContext.CurrentParam.DefaultValue}"/>
            <CheckBox Grid.Row="14"
                      Grid.Column="1"
                      Content="Globbing"
                      ToolTip="Indicates whether the parameter accepts wildcards"
                      IsChecked="{Binding EditorContext.ParamContext.CurrentParam.Globbing}"/>
        </Grid>
		<ListView DockPanel.Dock="Bottom"
				  Margin="10,0,10,0"
				  Name="lvParameters"
				  SelectionChanged="lvParametersSelectionChanged"
				  IsTabStop="True"
				  ItemsSource="{Binding EditorContext.CurrentCmdlet.Parameters}"
				  SelectedIndex="{Binding EditorContext.ParamIndex}"
		          x:FieldModifier="private"
				  ItemContainerStyle="{StaticResource ParamItemContStyle}">
			<ListView.View>
				<GridView>
					<GridViewColumn Header="Name" Width="200">
						<GridViewColumn.CellTemplate>
							<DataTemplate>
								<TextBlock Text="{Binding Name}"
                                           TextWrapping="NoWrap"
                                           TextTrimming="CharacterEllipsis"
                                           HorizontalAlignment="Stretch"
                                           ToolTip="{Binding Name}" />
							</DataTemplate>
						</GridViewColumn.CellTemplate>
					</GridViewColumn>
					<GridViewColumn Header="Description" Width="300">
						<GridViewColumn.CellTemplate>
							<DataTemplate>
								<TextBlock Height="16"
                                           Text="{Binding Description}"
                                           TextWrapping="NoWrap"
                                           TextTrimming="CharacterEllipsis"
                                           HorizontalAlignment="Stretch"
                                           ToolTip="{Binding Description}" />
							</DataTemplate>
						</GridViewColumn.CellTemplate>
					</GridViewColumn>
				</GridView>
			</ListView.View>
		</ListView>
	</DockPanel>
</UserControl>
